package visualizer;

class ChangeLight implements Runnable {
    int signal;
    int pauss, redpauss, greenpauss;
    Thread lighter;

    ChangeLight(){
       signal=1;
       redpauss=6000;
       greenpauss=6000;
   }

    public void run() {
                  signal=1;
    	while (true) {
    	    if (signal==1){
                          signal=0;
                          pauss=greenpauss;
                      }
                      else {
                          signal=1;
                          pauss=redpauss;
                      }
    	    try {
    		Thread.sleep(pauss);
    	    } catch (InterruptedException e) {
    		break;
    	    }
    	}
        }
        public void start() {
    	lighter = new Thread(this);
    	lighter.start();
        }
        public void stop() {
    	lighter.stop();
        }
    }  